package GameOntology;

import javax.swing.*;
import java.awt.*;

public abstract class GameObject {
    //物品的宽高
    private int width;
    private int height;
    //物品的图片
    private ImageIcon img;



    public GameObject() {
    }

    //物品的坐标
    private int x;
    private int y;

    private Rectangle rec=new Rectangle(x,y,width,height);

    public GameObject(int width, int height, String img, int x, int y) {
        this.width = width;
        this.height = height;
        this.img = new ImageIcon(img);
        this.x = x;
        this.y = y;
        renewalRec(x,y,width,height);
    }

    public void setImg(String img) {
        this.img = new ImageIcon(img);
    }

    public ImageIcon getImg() {
        return img;
    }

    public int getX() {
        return x;
    }

    public int getWidth() {
        return width;
    }

    public int getHeight() {
        return height;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }

    public Rectangle getRec() {
        return rec;
    }

    public void setRec(Rectangle rec) {
        this.rec = rec;
    }
    public void renewalRec(int x, int y,int width, int height){
        setRec(new Rectangle(x,y,width,height));
    }
}
